// JavaScript Document
$(function(){



var Roll = function(n){var result = 2160 + (n*60);$('#Border').rotate({angle:0,duration: 5000,animateTo: result,callback:callBack})};

var callBack = function(){
	t = 0;alert(lastData);
	//location.reload();
	$('#Border').rotate(0);
	$('#outframe').removeClass().addClass("RollBoard");
}




var lastData='';
$('.start').click(function(){
	var tcount = parseInt($('#tcount').text());
	var ucount = parseInt($('#ucount').text());
	if(tcount-ucount<=0){alert('您已经没有机会喽！');return;}
	
	$('#outframe').removeClass().addClass("RollBoard_1");
	
	$.post('/sroll.php',{act:'Roll'},function(data){
		
		if(data.cmd=="notlogin"){
			location.href="/login.php";
		}else{
		
			if(data.cmd=="0"){
			
				lastData = data.msg;
				$('#tcount').text( data.tcount);
				$('#ucount').text( data.ucount);
				Roll(data.num);
			}else if(data.cmd=="1" || data.cmd=="2"){
				alert(data.msg);
				location.href="/agent.php";
				return ;
			}else{
				alert(data.msg);
				return ;
			}
		}
		
		
	},"json");
	
});



});